Skip to content

Feat/validate prod deps ci#651

Open
annajowang wants to merge 1 commit into
mainfrom
feat/validate-prod-deps-ci
Open

Feat/validate prod deps ci#651
annajowang wants to merge 1 commit into
mainfrom
feat/validate-prod-deps-ci

Conversation

@annajowang

@annajowang annajowang commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR introduces a robust package verification step to our CI workflow to ensure that published packages do not have missing production dependencies (which were previously masked by monorepo hoisting).
During implementation, this verification script successfully identified and fixed a pre-existing missing dependency bug in @apphosting/build.

Key Changes

  1. Isolated Package Verification (scripts/verify-packages.js):
    • Added a script that packs each package and installs it in a clean, isolated temporary directory.
    • It installs only the package's own tarball, its declared local workspace dependencies, and required peer dependencies.
    • Verifies libraries via import() and CLI tools by running them with --help.
    • Supports delta builds by automatically skipping verification for packages that were not compiled in the current run (missing dist folder).
  2. Adapter Binary Refactoring (isMain Guards):
    • Added isMain(import.meta) guards to the Next.js and Angular adapter binaries (build.ts and create.ts).
    • This allows the verification script to verify these binaries by importing them (resolves static imports to catch missing dependencies like semver) without triggering their build execution logic.
  3. CI Integration:
    • Added the verify_packages job to .github/workflows/test.yml that runs after the build job.
  4. Bug Fix:
    • Added the missing yaml dependency to packages/@apphosting/build/package.json (discovered by the new verification script).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds environment variable validation for the Angular adapter, implements help flag support for the Angular and Next.js adapter build and create tools, and introduces a new package verification script. Feedback on the verification script recommends using npm pack --json to reliably parse generated tarball filenames and wrapping shell arguments in quotes to safely handle paths containing spaces.

Comment thread scripts/verify-packages.js Outdated
Comment on lines +42 to +44
const output = execSync("npm pack", { cwd: pkgPath, encoding: "utf8" }).trim();
// npm pack might output multiple lines if there are warnings, get the last line which should be the tarball name
const tarballName = output.split("\n").pop().trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Parsing the last line of npm pack output to find the tarball filename is fragile and can easily break if npm outputs warnings or other messages to stdout. Using npm pack --json is a much more robust and reliable way to programmatically retrieve the generated tarball filename.

Suggested change
const output = execSync("npm pack", { cwd: pkgPath, encoding: "utf8" }).trim();
// npm pack might output multiple lines if there are warnings, get the last line which should be the tarball name
const tarballName = output.split("\n").pop().trim();
const output = execSync('npm pack --json', { cwd: pkgPath, encoding: 'utf8' });
const tarballName = JSON.parse(output)[0].filename;

Comment thread scripts/verify-packages.js Outdated
Comment on lines +77 to +80
execSync(`npm install --no-audit --no-fund ${peerDeps.join(" ")} ${tarballs.join(" ")}`, {
cwd: testProjDir,
stdio: "inherit",
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the temporary directory path or any of the package paths contain spaces (which is common in some environments or OS configurations), passing them unquoted to execSync will cause the shell command to fail or behave unexpectedly. Wrapping the arguments in double quotes ensures the command runs successfully regardless of spaces in paths.

Suggested change
execSync(`npm install --no-audit --no-fund ${peerDeps.join(" ")} ${tarballs.join(" ")}`, {
cwd: testProjDir,
stdio: "inherit",
});
const installArgs = [...peerDeps, ...tarballs].map(arg => '"' + arg + '"').join(' ');
execSync('npm install --no-audit --no-fund ' + installArgs, {
cwd: testProjDir,
stdio: 'inherit',
});

@annajowang annajowang force-pushed the feat/validate-prod-deps-ci branch 4 times, most recently from 5a16421 to 6284b32 Compare June 15, 2026 23:25
Verify that the built packages can be installed and run (exiting with 0 when called with --help) in a clean environment without devDependencies. This catches cases where devDependencies are accidentally used as production dependencies.

Added --help support to nextjs and angular adapter build/create binaries to allow them to exit early with success instead of trying to run a full build/create during verification.

BUG=b/466103915
TAG=agy
CONV=25a32dbb-c6bf-4394-be10-d693f5f74670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant